package com.bingxue.edu.management.education.model.entity;

import com.bingxue.edu.common.enums.ClassCategoryEnum;
import com.bingxue.edu.common.enums.ClassStatusEnum;
import com.bingxue.edu.common.enums.SaleStatusEnum;
import com.bingxue.edu.common.enums.TermEnum;
import com.bingxue.edu.framework.common.model.BusinessEntity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 班级信息
 *
 * @author zq
 * @since 2024/08/21
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Table("edu_class_info")
public class ClassInfo extends BusinessEntity {

    @Schema(description = "名称")
    private String name;

    @Schema(description = "教学年份")
    private Integer classYear;

    @Schema(description = "入学年份限制")
    private Integer admissionYearLimit;

    @Schema(description = "学期")
    private TermEnum term;

    @Schema(description = "年级")
    private String grade;

    @Schema(description = "科目")
    private String subject;

    @Schema(description = "班级分类")
    private ClassCategoryEnum classCategory;

    @Schema(description = "班型")
    private String classTypeId;

    @Schema(description = "班级等级限制（冗余字段）")
    private Integer classLevelLimit;

    @Schema(description = "校区")
    private String campusId;

    @Schema(description = "教室")
    private String classroomId;

    @Schema(description = "主讲老师")
    private String leadTeacherId;

    @Schema(description = "辅导老师")
    private String assistTeacherId;

    @Schema(description = "计划招生")
    private Integer planStudentCount;

    @Schema(description = "报名人数")
    private Integer enrollStudentCount;

    @Schema(description = "通过人数")
    private Integer passedStudentCount;

    @Schema(description = "排课次数")
    private Integer totalLessonCount;

    @Schema(description = "已上课数")
    private Integer completedLessonCount;

    @Schema(description = "排课模板")
    private String arrangeTemplateId;

    @Schema(description = "时间模板")
    private String timeTemplateId;

    @Schema(description = "允许调课次数")
    private Integer lessonChangeLimit;

    @Schema(description = "总价")
    private BigDecimal totalPrice;

    @Schema(description = "单价")
    private BigDecimal unitPrice;

    @Schema(description = "上架状态")
    private SaleStatusEnum saleStatus;

    @Schema(description = "班级状态")
    private ClassStatusEnum classStatus;

    @Schema(description = "续报开始时间")
    private LocalDateTime renewalStartTime;

    @Schema(description = "续报结束时间")
    private LocalDateTime renewalEndTime;

    @Schema(description = "开放报名时间")
    private LocalDateTime enrollStartTime;

    @Schema(description = "课程图片")
    private String image;

    @Schema(description = "课程描述")
    @Column(isLarge = true)
    private String description;

    @Schema(description = "前序班级id")
    private String prevClassId;

    @Schema(description = "课时业绩系数")
    private Double lessonHourFactor;

    @Schema(description = "销售业绩系数")
    private Double salePerformanceFactor;

    @Schema(description = "剩余名额")
    public Integer getRemainCount() {
        return this.getPlanStudentCount() - this.getEnrollStudentCount();
    }

    @Schema(description = "待支付人数")
    public Integer getPendingPayCount() {
        return this.getEnrollStudentCount() - this.getPassedStudentCount();
    }
}
